package com.xjh.basestudy.javabase.Internetprogram;

import java.io.IOException;
import java.io.OutputStream;
import java.net.Socket;

public class Client1 {
    public static void main(String[] args) throws IOException {
        //创建流套接字并将其连接到指定ip地址的指定端口号
//        Socket s = new Socket(InetAddress.getByName("xjh"),10000);
        //InetAddress.getByName()的操作是自动的，所以有时候不用写
        Socket s = new Socket("xjh",10000);
        //获取输出流，写数据
        OutputStream os = s.getOutputStream();
        os.write("hello，fany，i am coming".getBytes());
        //释放资源
        s.close();

    }

}
